package edu.nf.meituan.dao.order.shop.impl;

import edu.nf.meituan.dao.order.shop.ShopOrderDAO;
import edu.nf.meituan.model.order.user.UserOrder;
import edu.nf.meituan.model.order.user.UserOrdersItem;
import edu.nf.util.DBUtils;
import org.nf.db.util.SqlExecutor;
import org.nf.db.util.result.BeanListHandler;

import java.util.List;

public class ShopOrderDAOImpl implements ShopOrderDAO {
    @Override
    public List<UserOrder> queryShopOrder(int id) {
        SqlExecutor executor = new SqlExecutor(DBUtils.getConnection());
        String sql = "SELECT order_id , rider_id , orders_status , shop_img , shop_name FROM orders INNER JOIN shop ON orders.shop_id = shop.shop_id WHERE orders.shop_id = ?";
        return executor.executeQuery(sql, new BeanListHandler<>(UserOrder.class),id);
    }

    @Override
    public int updateOrderStatus(int orderId, int status) {
        SqlExecutor executor = new SqlExecutor(DBUtils.getConnection());
        String sql = "UPDATE orders SET orders_status = ? WHERE order_id = ?";
        return executor.executeUpdate(sql,status,orderId);
    }

    @Override
    public List<UserOrdersItem> queryShopOrdersItem(int orderId) {
        return null;
    }

}
